package com.coolwar.controller;

import com.coolwar.api.internal.FenciApi;
import com.coolwar.common.basic.Enum.BasicCode;
import com.coolwar.common.basic.UtilsTools.Return;
import com.coolwar.interceptor.防刷拦截器.AccessLimit;
import com.coolwar.model.vo.VoFenci;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @author Coolwar
 */
@RestController
@RequestMapping("/test")
public class AController {

    private final Logger logger = LogManager.getLogger(AController.class);

    @Resource
    private FenciApi fenciApi;

    @AccessLimit(seconds = 1, maxCount = 1)
    @RequestMapping("/test")
    public Return test(HttpServletRequest request) {
        logger.info("【测试接口】开始：{}", request.getParameterMap());
        Map<String, Object> ret = new HashMap<>();
        ret.put("time", new Date());
        logger.info("【测试接口】完成");
        return Return.SUCCESS(BasicCode.success).data(ret);
    }

    @RequestMapping("/sentenceProcess")
    public Return sentenceProcess() {
        logger.info("【句子分词处理】开始");
        VoFenci sdf = fenciApi.sentenceProcess("哈哈手动阀");
        logger.info("【句子分词处理】完成");
        Map<String, Object> ret = new HashMap<>();
        ret.put("trackId", UUID.randomUUID().toString().replace("-", ""));
        ret.put("time", new Date());
        return Return.SUCCESS(BasicCode.success).data(ret);
    }

}
